<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>

    <script src="./js/vue.js"></script>
    <script>
      // 根组件
      new Vue({
        el: "#app",

        data: {
          msg: "hello",
        },

        template: `
            <div>
                <!--
                <base-input :value="msg" @input="onMyInput" />

                <base-input :value="msg" @input="msg = $event" />
                -->
                
            </div>
        `,

        methods: {
          onMyInput(event) {
            console.log("父组件", event);
            this.msg = event;
          },
        },

        components: {
          "base-input": {
            // options

            // props: ["msga"],
            props: ["value"],
            template: `
                    <div>
                        <input type="text" placehold="请输入" :value="value" @input="onInput" />    
                    </div>
                `,
            methods: {
              onInput(event) {
                console.log(event.target.value);
                // this.$emit("my-input", event.target.value);
                this.$emit("input", event.target.value);
              },
            },
          },
        },
      });
    </script>
  </body>
</html>
